﻿#ifndef SIDEDISPLAYFRAME_H
#define SIDEDISPLAYFRAME_H

#include <QWidget>
#include "SHttpClient.h"
#include "SApp.h"
#include <QStandardItemModel>
#include <QBrush>
#include "SHeaderView.h"
#include "CheckDelegate.h"
#include "FieldNameTranslate.h"
#include "UrlDelegate.h"
#include "EnableSwitchDelegate.h"
#include "SSwitchButton.h"
#include "ButtonDelegate.h"
#include "UserDetailShowDlg.h"
#include "UserAddDlg.h"
#include <set>
#include <QMap>
#include "MaskWidget.h"
#include <QMenu>
#include <QFileDialog>

#include "xlsxdocument.h"			//文档
#include "xlsxworksheet.h"			//工作表
#include "xlsxworkbook.h"			//工作簿




namespace Ui
{
	class Form;
}

class SideDisplayFrame:	public QWidget
{
	Q_OBJECT
private:
	Ui::Form* m_ui{};

	QStandardItemModel* m_model{};


	//获取一个字符串列表；		按照该顺序插入对应的数据：
	QStringList m_fieldnames = { "", "user_id","username","gender","mobile","email","isEnable" ,"controls" };
	int fieldnameColumn(const QString& field);

	//保存用户的密码：
	QMap<QString,QString> m_userpassword{};


	UserDetailShowDlg* m_userdetailshow{};

	UserAddDlg* m_useradddlg{};

	QPushButton* m_addUserBtn{};


	QMenu* m_importmenu{};

	QPushButton* pre_PageBtn{};
	QLabel* cur_PageLab{};
	QPushButton* next_PageBtn{};

public:
	SideDisplayFrame(QWidget* parent = nullptr);
	~SideDisplayFrame();

	void init();
	void delegateinit(SHeaderView* headerview);

public:
	//搜索框响应：
	void ResponseSearch();

	void setBatchEnable(bool isEn);

	void onEnable();
	void onDisable();
	void onDelete();

private:
	void Menuinit();
	void Single_Import();
	void Batch_Import();

	void parse_CSV_file(const QString& filename);
	void parse_XLSX_file(const QString& filename);

public:
	void parseJson(const QJsonObject& object);
	QList<QStandardItem*> ItemsFromJsonObject(const QJsonObject& juser);

};

#endif // !SIDEDISPLAYFRAME_H
